/*
A Pythagorean triplet is a set of three natural numbers, a &lt; b &lt; c, for which,
 a2 + b2 = c2
For example, 32 + 42 = 9 + 16 = 25 = 52.
There exists exactly one Pythagorean triplet for which a + b + c = 1000.Find the product abc.

Anser:31875000
Time:73.747µs
*/
package main

import (
	"fmt"
	"time"
)

func main() {
	tstart := time.Now()
	func() {
		var c, d int
		for a := 1; a < 300; a++ {
			for b := 250; b < 500; b++ {
				c = 1000 - a - b
				d = a*a + b*b - c*c
				if d > 0 {
					break
				}
				if d == 0 {
					fmt.Println(a * b * c)
					return
				}
			}
		}
	}()
	tend := time.Now()
	fmt.Println(tend.Sub(tstart))
}
